Welcome Guest | Sign in | Register
.NET Programming Concepts - DotNet Programming Interview Questions and Answers | LucentBlackBoard | LucentBlackBoard.com

Home > Technical Interviews > Computer Science & Engineering > DotNet Programming > .NET Programming Concepts Questions and Answers

16. What is the main difference between sub-procedure and function?

The sub-procedure is a block of multiple visual basic statements within Sub and End Sub statements. It is used to perform certain tasks, such as changing properties of objects, receiving or processing data, and displaying an output. You can define a sub-procedure anywhere in a program, such as in modules, structures, and classes.

We can also provide arguments in a sub-procedure; however, it does not return a new value.
The function is also a set of statements within the Function and End Function statements. It is similar to sub-procedure and performs the same task. The main difference between a function and a sub-procedure is that sub-procedures do not return a value while functions do.

17. Determine the output of the code snippet.

int a = 29;
a--;
a -= ++a;
Console.WriteLine("The value of a is: {0}", a);

/* The output of the code is -1. */

18. Differentiate between Boxing and Unboxing.

When a value type is converted to an object type, the process is known as boxing; whereas, when an object type is converted to a value type, the process is known as unboxing.

Boxing and unboxing enable value types to be treated as objects. Boxing a value type packages it inside an instance of the Object reference type. This allows the value type to be stored on the garbage collected heap. Unboxing extracts the value type from the object. In this example, the integer variable i is boxed and assigned to object obj.

Example:
int i = 123;
object obj = i; /* Thi line boxes i. */

/* The object obj can then be unboxed and assigned to integer variable i: */
i = (int)obj; // unboxing 

19. Give the syntax of using the for loop in C# code?

The syntax of using the for loop in C# code is given as follows:
for(initializer; condition; loop expression)
{
//statements
}

In the preceding syntax, initializer is the initial value of the variable, condition is the expression that is checked before the execution of the for loop, and loop expression either increments or decrements the loop counter.

The example of using the for loop in C# is shown in the following code snippet:
for(int i = 0; i < 5; i++)
Console.WriteLine("Hello");

In the preceding code snippet, the word Hello will be displayed for five times in the output window.




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.